home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-05-13 | 4.0 KB | 93 lines | [TEXT/MPS ] |
- Authors
- -------
- Craig Hotchkiss
- Chris Halim
-
- Steps to create your own choose dialog:
- =======================================
- ASSUMPTIONs - In the following text, xx can currently be CM, FT, or TM (the future
- does hold other possibilities). For example, xxChoose could be CMChoose, FTChoose,
- or TMChoose.
-
- InitGlobals
- Create storage -- This step is necessary to create the private storage needed
- by CTB and the tools for dialog operation. The CTB calls will
- dereference your pointer and expect the first 6 bytes of this structure to be:
- 2 bytes (short) - tool procID - A.K.A. tool refNum.
- 4 bytes (long) - internal tool use.
- NOTE -- Remember that you can extend this structure to include any private
- storage -- similar to using a pointer to the following structure as a WindowPtr:
- struct {
- WindowRecord fWRecord;
- Ptr fPrivateStorage;
- } myWindowRec, *myWindowPtr;
- you can also create your own private storage by extending the structure that
- the CTB calls expect. Here's an example:
- struct {
- short fProcID; // for CTB
- long fMagicCookie; // for CTB
- /* now we're free to add our own stuff.
- Ptr fConfigPtr; // for our use
- short fItemCount; // for our use
- ProcPtr fIdleProc; // for our use
- etc...
- } ChooseDLOGData, *ChooseDLOGDataPtr;
- GetNewDialog - This is a dialog that contains the common elements between
- tools. For those folks who have seen the xxChoose dialog, an example of this
- dialog would be a small window frame just large enough to contain non-tool-
- specific items like OK and Cancel buttons, the tool name popup menu, and
- the dotted line. The tool appends its item list to this "base" dialog so
- the frame of the window itself only needs to encompass the items you provide.
- Perform any dialog positioning.
- Set window refCon to the storage ptr you created in the first step -- this is
- necessary in preparation for the xxSetupxx calls to come.
- Save CurResFile().
- Save the current grafPtr.
- Set the new grafPtr to the dialog.
- Set CurResFile() to the procID of the tool we're working with (the tool procID
- is also the refNum of the open file).
- Call xxSetupPreflight
- Call AppendDITL with handle to itemList that xxSetupPreflight returns.
- Call xxSetupSetup to display the items.
- Do ModalDialog with a filter proc
- Modal Filter proc
- Perform any other normal event handling
- Set CurResFile() to the procID of the tool we're working with (the tool procID
- is also the refNum of the open file).
- Call xxSetupFilter
- Call the idleProc if provided
- END
- While the itemHit is NOT OK or Cancel
- Handle any others items we provide
- or
- If the itemHit > itemCount it must be a CTB item
- Set CurResFile() to the procID of the tool we're working with (the tool
- procID is also the refNum of the open file).
- Call xxSetupItem
- END
- Important - Set the new grafPtr to the dialog.
- Set CurResFile() to the procID of the tool we're working with (the tool procID
- is also the refNum of the open file).
- Call xxSetupXCleanup
- Call ShortenDITL
- Call xxPostflight
- Cleanup any private items you provide.
- Restore the saved GrafPtr
- Restore the saved CurResFile()
- If OK was hit, update the configuration record and validate it else do nothing.
-
-
- -------------------------------------------------------------------------------------
- DISCLAIMER - This paper contains hints to assist CommToolbox software developers with
- their efforts at producing awesome products. They are just hints (a form of help)
- however, and are not intended to represent the only possible solution.
-
- It should also be noted that this paper describes current CommToolbox interface
- usage and while the CTB interface could change, upwards-compatibility will remain a
- focus of the CTB production team wherever possible. Therefore the hints contained
- in this document that use the changing CTB interface represent a solution that should
- remain viable.
- -------------------------------------
- Copyright © 1992 Apple Computer, Inc.
- All rights reserved.
-